<!DOCTYPE html>
<html>
  <head>
    <title><%= title %></title>
    <link rel='stylesheet' href='/stylesheets/style.css' />
  </head>
  <body>
    <div class="box">
      <input type="text" name="" id="username">
      <input type="password" name="" id="password">
      <button type="submit" id="btn">登录</button>
    </div>
    <script>
      var username=document.querySelector('#username')
      var password=document.querySelector('#password')
      var btn=document.querySelector('#btn')
      btn.onclick=function(){
        const uname=username.value;
        const pwd=password.value;
        if(uname=='' || pwd ==''){
          alert('请输入完整的信息')
          return
        }
        const xhr=new XMLHttpRequest();
        xhr.open('post','/api/login')
        xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        xhr.send(`userName=${uname}&passWord=${pwd}`)
        xhr.onload=function(){
          console.log('res',typeof(xhr.response))
        }
      }
    </script>
  </body>
</html>
